package com.macaupass.sdkDemo.wxapi

import android.os.Bundle
import android.widget.Toast

import com.macau.pay.sdk.base.activity.WXCallbackActivity
import com.tencent.mm.opensdk.constants.ConstantsAPI
import com.tencent.mm.opensdk.modelbase.BaseReq
import com.tencent.mm.opensdk.modelbase.BaseResp

class WXPayEntryActivity : WXCallbackActivity() {
    public override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onResp(resp: BaseResp) {
        super.onResp(resp)
        if (resp.type == ConstantsAPI.COMMAND_PAY_BY_WX) {
            if (resp.errCode == 0) {
                finish()
            } else if (resp.errCode == -2) {
                Toast.makeText(this, "您已取消付款!", Toast.LENGTH_SHORT).show()
                finish()
            } else {
                Toast.makeText(this, "参数错误", Toast.LENGTH_SHORT).show()
                finish()
            }
        } else {
            finish()
        }

    }

    override fun onReq(req: BaseReq) {
        super.onReq(req)
    }
}
